package com.bridgeintelligent.tag.webserver.dim.mgmt.service.assess;

import com.bridgeintelligent.tag.webserver.dim.mgmt.api.BaseCode;
import com.bridgeintelligent.tag.webserver.dim.mgmt.api.DimRep;
import com.bridgeintelligent.tag.webserver.dim.mgmt.service.assess.model.AssessModel;
import com.bridgeintelligent.tag.webserver.dim.mgmt.service.assess.model.CombinationModel;
import com.bridgeintelligent.tag.webserver.dim.mgmt.service.assess.model.CustomersModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @description 标签评价
 * @author: grp 2020-09-03 10:54
 **/

@Api(tags = "标签评价")
@RestController
@AllArgsConstructor
@RequestMapping("/api/dimAssess")
@Validated
public class DimAssessController {

    private IAssessService assessService;
    @ApiOperation(value = "查询聚合信息", notes = "聚合信息")
    @GetMapping("query/{dimId}")
    public DimRep query(@NotBlank @PathVariable String dimId){
        return new DimRep<>(assessService.getInfo(dimId), BaseCode.SUCCESS);
    }

    @ApiOperation(value = "标签评价", notes = "评价")
    @PostMapping("assess")
    public DimRep assess(@RequestBody @Valid AssessModel assessModel){
        assessService.assess(assessModel);
        return new DimRep(BaseCode.SUCCESS);
    }

    @ApiOperation(value = "使用的组合标签列表", notes = "组合标签列表")
    @GetMapping("getUsedDims")
    public DimRep getUsedDims(@ModelAttribute @Valid CombinationModel model){
        model.setPageNumber(model.getPageNumber() == null ? 1 : model.getPageNumber());
        model.setPageSize(model.getPageSize() == null ? 10 : model.getPageSize());
        return assessService.getUsedDims(model);
    }

    @ApiOperation(value = "使用的客群列表", notes = "客群列表")
    @GetMapping("getUsedCustomers")
    public DimRep getUsedCustomers(@ModelAttribute @Valid CustomersModel model){
        model.setPageNumber(model.getPageNumber() == null ? 1 : model.getPageNumber());
        model.setPageSize(model.getPageSize() == null ? 10 : model.getPageSize());
        return assessService.getUsedCustomers(model);
    }

}
